﻿using CommunityToolkit.Mvvm.ComponentModel;
using MG.SmartHMI.Entity.DAO;

namespace MG.SmartHMI.Model
{
    public partial class BaseItemsControl : ObservableRecipient
    {
        [ObservableProperty]
        private string name;

        public RegisterConfig RegisterData { get; set; }

        public int SlnParmId { get; set; } = 0;
        public BaseItemsControl(RegisterConfig data)
        {
            RegisterData = data;
            Name = RegisterData.Name ?? "新建";
        }

        public BaseItemsControl()
        {
            RegisterData = new();
        }

        //读取时钟触发绑定
        //EventBus.Default.BindCircleTimeAction(CircleReadValueSlot);

        public virtual void UpdateRead()
        {
            // Default implementation does nothing, can be overridden by derived classes
        }

        public virtual void UpdateWrite()
        {
            // Default implementation does nothing, can be overridden by derived classes
        }

        /// <summary>
        /// 从批量读取后的源数据解析需要的结果
        /// data： 功能码批量读取的寄存器数据
        /// bdata：0X05 功能码批量读取的BOOL数据
        /// </summary>
        /// <param name="data">0X03 功能码批量读取的寄存器数据</param>
        /// <param name="bdata">0X05 功能码批量读取的BOOL数据</param>
        public virtual void ParsebyBatchData(ref byte[] data, ref bool[] bdata)
        { }
    }
}